﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Data.OleDb;

namespace 学生信息管理系统
{
    public partial class StudentPassword : Form
    {
        public StudentPassword()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            string cn_str = pub.CN_STR;
            OleDbConnection cn = new OleDbConnection(cn_str);              //建立数据库连接
            cn.Open();
            string select = "UPDATE  学生登录    SET         密码 ='" + txtPassword.Text + "'    WHERE   (学生登录.用户名 = '"+txtNo.Text+"')";
            OleDbCommand cmd = new OleDbCommand(select, cn);                 //建立数据库命令
            OleDbDataReader reader = cmd.ExecuteReader();
            if (this.txtPassword.Text == "")
            {
                MessageBox.Show("密码不能为空！", "", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                
            }
            else
            {
                MessageBox.Show("修改成功！", "", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                this.Close();
            }
            cn.Close();
        }

        private void StudentPassword_Load(object sender, EventArgs e)
        {

        }

        public StudentPassword(String s)
        {
            InitializeComponent();
            this.txtNo.Text = s;
        }

    }
}
